<%--
  Created by IntelliJ IDEA.
  User: gaosubo
  Date: 2020/9/9
  Time: 13:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>评分标准</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
    <script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.all.js?20200715.1" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/UEcontroller.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/formdesign/bootstrap/js/bootstrap.js?20200826" type="text/javascript" charset="utf-8"></script>
</head>
<style>
    .openFile input[type=file]{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }
</style>
<body>
<div>
    <form class="layui-form" action="" style="margin: 10px;" lay-filter="ajaxforms">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">验证日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="date" id="date" lay-verify="date" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div style="height: 30px;line-height: 30px;text-align: center;background: #f2f2f2;margin-bottom: 10px">标志性成果</div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 43px;  margin-right: 43px;">
                <div id="container" style="width: 99.9%;min-height: 300px;" name="content" type="text/plain"></div>
            </div>
        </div>
        <div class="layui-form-item"  style="margin-top:15px">
            <label class="layui-form-label" style="width: 100px;margin-left:-20px">开题报告</label>
            <div class="layui-input-inline">
                <div id="fujians"></div>
                <div id="fileAll">
                </div>
                <a href="javascript:;" class="openFile" style="float: left;margin-top:8px;position:relative">
                    <img src="../img/mg11.png" alt="">
                    <span>添加附件</span>
                    <input type="file" multiple id="fileupload" data-url="/upload?module=conclusion" name="file">
                </a>
            </div>
        </div>
        <div class="layui-form-item"  style="margin-top:15px">
            <label class="layui-form-label" style="width: 100px;margin-left:-20px">学段意见</label>
            <div class="layui-input-inline">
                <div id="fujians1"></div>
                <div id="fileAll1">
                </div>
                <a href="javascript:;" class="openFile" style="float: left;margin-top:8px;position:relative">
                    <img src="../img/mg11.png" alt="">
                    <span>添加附件</span>
                    <input type="file" multiple id="fileupload1" data-url="/upload?module=conclusion" name="file">
                </a>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 10px">
            <div class="layui-inline">
                <label class="layui-form-label">学段评分</label>
                <div class="layui-input-inline">
                    <input id="trOther2" type="tel" name="trOther2" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 10px">
            <div class="layui-inline">
                <label class="layui-form-label">课题组意见</label>
                <div class="layui-input-inline">
                    <input id="trOther6" type="tel" name="trOther6" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 10px">
            <div class="layui-inline">
                <label class="layui-form-label">科研组意见</label>
                <div class="layui-input-inline">
                    <input id="trOther9" type="tel" name="trOther9" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/html" id="planDel">
    <a class="layui-btn layui-btn-danger layui-btn-xs del2" lay-event="del2">删除</a>
</script>

<script>
    // 获取地址栏参数值
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }

    var trId = getQueryString('trId');
    var type = getQueryString('type');
    var table,form,laydate,upload,layedit;
    var ue;

    $(function(){
        ue = UE.getEditor('container',{elementPathEnabled : false});
        layui.use(['table', 'form', 'laydate','upload','layedit'], function () {
            table = layui.table,
                form = layui.form,
                laydate = layui.laydate,
                upload = layui.upload,
                layedit = layui.layedit;
            //日期
            laydate.render({
                elem: '#date'
                ,trigger: 'click'//呼出事件改成click
                ,type:'datetime'
                ,format: 'yyyy-MM-dd HH:mm:ss'
            });
            fileuploadFn('#fileupload', $('#fileAll'));
            //查看
            if(type==1){
                $.ajax({
                    url: '/conclusion_review/getDataByTrId',
                    dataType: 'json',
                    type: 'post',
                    data:{
                        trId:trId,
                        trType:getQueryString('trType')
                    },
                    success:function (res) {
                        var obj =res.object
                        $('#date').val(obj.trTime)
                        $('#date').attr('disabled','disabled')
                        //编辑器回显
                        ue.ready(function(){
                            if(obj.trOther){
                                ue.setContent(obj.trOther);
                            }
                        });
                        var str = '';
                        var str1 = ''
                        if(obj.attachmentList == undefined){
                            str='';
                            str1='';
                        }else if(obj.attachmentList.length>0){
                            // for(var i=0;i<obj.attachmentList.length;i++){
                            //     str+='<div class="dech" deUrl="' +obj.attachmentList[i].attUrl + '">' +
                            //         '<a href="/download?' + obj.attachmentList[i].attUrl + '" NAME="' + obj.attachmentList[i].attachName +'*">' +
                            //         '<img style="margin-right:10px;" src="/img/attachment_icon.png"/>' + obj.attachmentList[i].attachName + '</a>' +
                            //         '<img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/>' +
                            //         '<input type="hidden" class="inHidden" value="' + obj.attachmentList[i].aid + '@' + obj.attachmentList[i].ym + '_' + obj.attachmentList[i].attachId +',">' +
                            //         '</div>'
                            // }
                            str+='<div class="dech" deUrl="' +obj.attachmentList[0].attUrl + '">' +
                                '<a href="/download?' + obj.attachmentList[0].attUrl + '" NAME="' + obj.attachmentList[0].attachName +'*">' +
                                '<img style="margin-right:10px;" src="/img/attachment_icon.png"/>' + obj.attachmentList[0].attachName + '</a>' +
                                '<img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/>' +
                                '<input type="hidden" class="inHidden" value="' + obj.attachmentList[0].aid + '@' + obj.attachmentList[0].ym + '_' + obj.attachmentList[0].attachId +',">' +
                                '</div>'
                            str1+='<div class="dech" deUrl="' +obj.attachmentList[1].attUrl + '">' +
                                '<a href="/download?' + obj.attachmentList[1].attUrl + '" NAME="' + obj.attachmentList[1].attachName +'*">' +
                                '<img style="margin-right:10px;" src="/img/attachment_icon.png"/>' + obj.attachmentList[1].attachName + '</a>' +
                                '<img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/>' +
                                '<input type="hidden" class="inHidden" value="' + obj.attachmentList[1].aid + '@' + obj.attachmentList[1].ym + '_' + obj.attachmentList[1].attachId +',">' +
                                '</div>'
                        }
                        $('#fujians').html(str)
                        $('#fujians1').html(str1)
                        $('#trOther2').val(obj.trOther2)
                        if (obj.trOther6 == "1" || obj.trOther6 == 1) {
                            $('#trOther6').val("同意")
                        }
                        if (obj.trOther6 == "2" || obj.trOther6 == 2) {
                            $('#trOther6').val("不同意")
                        }
                        if (obj.trOther9 == "1" || obj.trOther9 == 1) {
                            $('#trOther9').val("同意")
                        }
                        if (obj.trOther9 == "2" || obj.trOther9 == 2) {
                            $('#trOther9').val("不同意")
                        }
                        $('.deImgs').hide()
                        form.render()
                    }
                })
            }
        });
        //删除附件
        $(document).on('click', '.deImgs', function () {
            var _this = this;
            var attUrl = $(this).parents('.dech').attr('deUrl');
            layer.confirm('确定删除该附件吗？', function (index) {
                $.ajax({
                    type: 'get',
                    url: '/delete?' + attUrl,
                    dataType: 'json',
                    success: function (res) {
                        if (res.flag == true) {
                            layer.msg('删除成功', {icon: 6, time: 1000});
                            $(_this).parent().remove();
                        } else {
                            layer.msg('删除失败', {icon: 2, time: 1000});
                        }
                    }
                })
            });
        });
    });


    //成果列表保存
    function listSubmit() {
        var obj = {}
        //附件
        var attachmentId = '';
        var attachmentName = '';
        for (var i = 0; i < $('#fileAll .dech').length; i++) {
            attachmentId += $('#fileAll .dech').eq(i).find('input').val();
            attachmentName += $('#fileAll a').eq(i).attr('name');
        }
        obj.trId = trId
        obj.trTime = $('#date').val()
        obj.trOther= ue.getContent()
        obj.attachmentId = attachmentId
        obj.attachmentName=attachmentName;
        $.ajax({
            url: '/conclusion_apply/uploadFile',
            dataType: 'json',
            type: 'post',
            data: obj,
            success: function (res) {
                if (res.msg == '修改成功') {
                    parent.closes();
                }
            }
        })
    }

</script>
</body>
</html>
